home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Camelot / Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].zip / Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].adf / XLisp-Stat / Book / regsensitivity.lsp < prev    next >
Text File  |  1990-10-11  |  1KB  |  35 lines

  1. ; book pp.307-308
  2.  
  3. (setf x (append (iseq 1 18) (list 30 40)))
  4. (setf y (+ x (* 2 (normal-rand 20))))
  5. (setf w (plot-points x y))
  6.  
  7. (send w :add-mouse-mode 'point-moving
  8.       :title "Point Moving"
  9.       :cursor 'finger
  10.       :click :do-point-moving)
  11.  
  12. (defmeth w :do-point-moving (x y a b)
  13.   (let ((p (send self :drag-point x y :draw nil)))
  14.     (if p (send self :set-regression-line))))
  15.  
  16. (defmeth w :set-regression-line ()
  17.   (let ((coefs (send self :calculate-coefficients)))
  18.     (send self :clear-lines :draw nil)
  19.     (send self :abline (select coefs 0) (select coefs 1))))
  20.  
  21. (defmeth w :calculate-coefficients ()
  22.   (let* ((i (send self :points-showing))
  23.          (x (send self :point-coordinate 0 i))
  24.          (y (send self :point-coordinate 1 i))
  25.          (m (regression-model x y :print nil)))
  26.    (send m :coef-estimates)))
  27.  
  28. (defmeth w :adjust-screen ()
  29.   (if (send self :needs-adjusting)
  30.       (send self :set-regression-line))
  31.   (call-next-method))
  32.  
  33. (send w :set-regression-line)
  34. (send w :mouse-mode 'point-moving)
  35.